package com.jianan.mis.app.overseastudy;

import static com.jianan.mis.util.ui.table.TableCreator.createSortedTableColumn;
import static com.jianan.mis.util.ui.table.TableCreator.createTableColumn;

import java.text.Collator;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;

import com.jianan.mis.data.cache.CountryCache;
import com.jianan.mis.data.dao.base.PageControl;
import com.jianan.mis.data.domain.Country;
import com.jianan.mis.data.domain.School;
import com.jianan.mis.service.SchoolService;
import com.jianan.mis.sys.IImageKeys;
import com.jianan.mis.sys.IMessageKeys;
import com.jianan.mis.sys.ImageManager;
import com.jianan.mis.sys.ResourceManager;
import com.jianan.mis.sys.SpringBeanFactory;
import com.jianan.mis.util.StringUtils;
import com.jianan.mis.util.ui.table.AbstractInvertableTableSorter;

public class SchoolArchiveView extends ViewPart {

	private Text txtState;
	private Text txtSpeciality;
	private Combo comboCountry;
	class TableLabelProvider extends LabelProvider implements ITableLabelProvider {
		public String getColumnText(Object element, int columnIndex) {
			School school = (School) element;
			String text = schools.getColumn(columnIndex).getText();
			if (text.equals(SCHOOL_NAME)) {
				return school.getName();
			} else if (text.equals(COUNTRY_NAME)) {
				return school.getCountry().getName();
			} else if (text.equals(COPARTNER)) {
				return school.getCopartner();
			} else if (text.equals(PUBLIC)) {
				return school.isPublic() ? "公立" : "私立";
			} else if (text.equals(PROPERTY)) {
				return school.getProperty();
			} else if (text.equals(STATE)) {
				if (school.getState() != null)
					return school.getState();
				else
					return "";
			} else if (text.equals(CITY)) {
				if (school.getCity() != null)
					return school.getCity();
				else
					return "";
			} else if (text.equals(DOUBLE_MATRICULATE)) {
				if (school.isDoubleMatriculate() == true)
					return "是";
				else
					return "否";
			} else if (text.equals(ENTER_REQUIREMENT)) {
				if (school.getEnterRequirement() != null)
					return school.getEnterRequirement();
				else
					return "";
			} else if (text.equals(PHONE_INTERVIEW)) {
				if (school.isPhoneInterview() == true)
					return "是";
				else
					return "否";
			} else if (text.equals(FEE)) {
				return school.getFee().toString();
			} else if (text.equals(LANG_REQ)) {
				return school.getLangReq();
			} else if (text.equals(APPLY_FEE)) {
				if (school.getApplyFee() != null)
					return school.getApplyFee().toString();
				else
					return "";
			} else if (text.equals(APPLY_END_DATE)) {
				if (school.getApplyEndDate() != null)
					return dateFormat.format(school.getApplyEndDate());
				else
					return "";
			} else if (text.equals(GRADUATE_RATE)) {
				if (school.getGraduateRate() != null)
					return "%" + school.getGraduateRate().toString();
				else
					return "";
			} else if (text.equals(RANK)) {
				if (school.getRank() != null)
					return school.getRank().toString();
				else
					return "";
			} else if (text.equals(STUDENT_COUNT)) {
				if (school.getStudentCount() != null)
					return school.getStudentCount().toString();
				else
					return "";
			} else if (text.equals(OVERSEA_STUDENT_RATE)) {
				if (school.getOverseaStudentRate() != null)
					return "%" + school.getOverseaStudentRate().toString();
				else
					return "";
			} else if (text.equals(SCHOLARSHIP)) {
				return school.getScholarship();
			} else if (text.equals(WEBSITE)) {
				return school.getWebsite();
			} else if (text.equals(REMARK)) {
				return school.getRemark();
			} else {
				return null;
			}
		}
		public Image getColumnImage(Object element, int columnIndex) {
			return null;
		}
	}
	class ContentProvider implements IStructuredContentProvider {
		public Object[] getElements(Object inputElement) {
			return ((List) inputElement).toArray();
		}
		public void dispose() {
		}
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		}
	}
	private Label lblResult;
	private Label lblPage;
	private Combo comboScholarship;
	private Combo comboProperty;
	private Combo comboPublic;
	private Text txtName;
	
	private TableViewer schoolTableViewer;
	private Table schools;
	public static final String ID = "com.jianan.mis.app.overseastudy.SchoolArchiveView"; //$NON-NLS-1$
	
	private String[] properties = new String[] {"语言", "高中", "衔接与预科", "大学", "研究生", "寄宿", "A-Levels"};

	final private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
	final private int PAGE_SIZE = 15;
	private PageControl pageControl;
	private Map conditions;

	/**
	 * Create contents of the view part
	 * @param parent
	 */
	@Override
	public void createPartControl(Composite parent) {
		final FillLayout fillLayout = new FillLayout();
		fillLayout.marginHeight = 10;
		fillLayout.marginWidth = 10;
		parent.setLayout(fillLayout);
		Composite container = new Composite(parent, SWT.NONE);
		final GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 4;
		gridLayout.makeColumnsEqualWidth = true;
		container.setLayout(gridLayout);

		final Label label = new Label(container, SWT.NONE);
		label.setFont(ResourceManager.getFont("", 10, SWT.BOLD));
		label.setText("查询条件:");
		new Label(container, SWT.NONE);
		new Label(container, SWT.NONE);
		new Label(container, SWT.NONE);

		final Label label_1 = new Label(container, SWT.NONE);
		label_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
		label_1.setText("学校名称:");

		txtName = new Text(container, SWT.BORDER);
		final GridData gd_txtName = new GridData(SWT.LEFT, SWT.CENTER, true, false);
		gd_txtName.widthHint = 150;
		txtName.setLayoutData(gd_txtName);

		final Label label_2 = new Label(container, SWT.NONE);
		label_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
		label_2.setText("公私立:");

		comboPublic = new Combo(container, SWT.READ_ONLY);
		comboPublic.setItems(new String[] {"公立", "私立"});
		final GridData gd_comboPublic = new GridData(SWT.LEFT, SWT.CENTER, true, false);
		comboPublic.setLayoutData(gd_comboPublic);

		final Label label_3 = new Label(container, SWT.NONE);
		label_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
		label_3.setText("学校性质:");

		comboProperty = new Combo(container, SWT.READ_ONLY);
		comboProperty.setItems(properties);
		final GridData gd_comboProperty = new GridData(SWT.LEFT, SWT.CENTER, true, false);
		comboProperty.setLayoutData(gd_comboProperty);

		final Label label_4 = new Label(container, SWT.NONE);
		label_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
		label_4.setText("奖学金:");

		comboScholarship = new Combo(container, SWT.READ_ONLY);
		comboScholarship.setItems(new String[] {"有", "无"});
		final GridData gd_comboScholarship = new GridData(SWT.LEFT, SWT.CENTER, true, false);
		comboScholarship.setLayoutData(gd_comboScholarship);

		final Label label_6 = new Label(container, SWT.NONE);
		label_6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
		label_6.setText("国家:");

		comboCountry = new Combo(container, SWT.NONE);
		final GridData gd_comboCountry = new GridData(SWT.LEFT, SWT.CENTER, true, false);
		comboCountry.setLayoutData(gd_comboCountry);

		final Label label_8 = new Label(container, SWT.NONE);
		label_8.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
		label_8.setText("所在州:");

		txtState = new Text(container, SWT.BORDER);
		final GridData gd_txtState = new GridData(SWT.LEFT, SWT.CENTER, true, false);
		gd_txtState.widthHint = 100;
		txtState.setLayoutData(gd_txtState);

		final Label label_7 = new Label(container, SWT.NONE);
		label_7.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
		label_7.setText("专业:");

		txtSpeciality = new Text(container, SWT.BORDER);
		final GridData gd_txtSpeciality = new GridData(SWT.LEFT, SWT.CENTER, true, false);
		gd_txtSpeciality.widthHint = 160;
		txtSpeciality.setLayoutData(gd_txtSpeciality);
		new Label(container, SWT.NONE);
		new Label(container, SWT.NONE);
		new Label(container, SWT.NONE);

		final Button btnQuery = new Button(container, SWT.NONE);
		btnQuery.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent e) {
				pageControl = new PageControl(PAGE_SIZE);
				buildQueryConditions();
				pageQuery();
			}
		});
		final GridData gd_btnQuery = new GridData(SWT.CENTER, SWT.CENTER, false, false);
		btnQuery.setLayoutData(gd_btnQuery);
		btnQuery.setText("查询");
		btnQuery.setImage(ImageManager.getImage(IImageKeys.SEARCH));

		final Button btnReset = new Button(container, SWT.NONE);
		btnReset.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent e) {
				txtName.setText("");
				comboPublic.deselectAll();
				comboProperty.deselectAll();
				comboScholarship.deselectAll();
				comboCountry.deselectAll();
				txtState.setText("");
				txtSpeciality.setText("");
			}
		});
		final GridData gd_btnReset = new GridData(SWT.CENTER, SWT.CENTER, false, false);
		btnReset.setLayoutData(gd_btnReset);
		btnReset.setText("重置");
		btnReset.setImage(ImageManager.getImage(IImageKeys.RESET));
		
		new Label(container, SWT.NONE);final Label label_5 = new Label(container, SWT.NONE);
		label_5.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
		label_5.setFont(ResourceManager.getFont("", 10, SWT.BOLD));
		label_5.setText("查询结果:");
		
		new Label(container, SWT.NONE);

		new Label(container, SWT.NONE);
		
		lblResult = new Label(container, SWT.NONE);
		lblResult.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
		lblResult.setText("");

		lblPage = new Label(container, SWT.NONE);
		lblPage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
		lblPage.setText("");

		final Button btnFirstPage = new Button(container, SWT.NONE);
		btnFirstPage.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent e) {
				if (pageControl == null) {
					MessageDialog.openInformation(e.display.getActiveShell(),
							IMessageKeys.FAIL, "请先进行查询!");
					return;
				}
				if (pageControl.getPageCount() > 0) {
					pageControl.setPageNo(1);
					pageQuery();
				}
			}
		});
		final GridData gd_btnFirstPage = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
		btnFirstPage.setLayoutData(gd_btnFirstPage);
		btnFirstPage.setText("首页");
		btnFirstPage.setImage(ImageManager.getImage(IImageKeys.LEFT));

		final Button btnPrevPage = new Button(container, SWT.NONE);
		btnPrevPage.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent e) {
				if (pageControl == null) {
					MessageDialog.openInformation(e.display.getActiveShell(),
							IMessageKeys.FAIL, "请先进行查询!");
					return;
				}
				if (pageControl.getPageNo() - 1 > 0) {
					pageControl.setPageNo(pageControl.getPageNo() - 1);
					pageQuery();
				}
			}
		});
		final GridData gd_btnPrevPage = new GridData(SWT.CENTER, SWT.CENTER, false, false);
		btnPrevPage.setLayoutData(gd_btnPrevPage);
		btnPrevPage.setText("上页");
		btnPrevPage.setImage(ImageManager.getImage(IImageKeys.UP));

		final Button btnNextPage = new Button(container, SWT.NONE);
		btnNextPage.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent e) {
				if (pageControl == null) {
					MessageDialog.openInformation(e.display.getActiveShell(),
							IMessageKeys.FAIL, "请先进行查询!");
					return;
				}
				if (pageControl.getPageNo() + 1 <= pageControl.getPageCount()) {
					pageControl.setPageNo(pageControl.getPageNo() + 1);
					pageQuery();
				}
			}
		});
		btnNextPage.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
		btnNextPage.setText("下页");
		btnNextPage.setImage(ImageManager.getImage(IImageKeys.DOWN));

		final Button btnLastPage = new Button(container, SWT.NONE);
		btnLastPage.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent e) {
				if (pageControl == null) {
					MessageDialog.openInformation(e.display.getActiveShell(),
							IMessageKeys.FAIL, "请先进行查询!");
					return;
				}
				if (pageControl.getPageCount() > 0) {
					pageControl.setPageNo(pageControl.getPageCount());
					pageQuery();
				}
			}
		});
		btnLastPage.setLayoutData(new GridData());
		btnLastPage.setText("尾页");
		btnLastPage.setImage(ImageManager.getImage(IImageKeys.RIGHT));

		schoolTableViewer = new TableViewer(container, SWT.FULL_SELECTION | SWT.BORDER);
		schoolTableViewer.setLabelProvider(new TableLabelProvider());
		schoolTableViewer.setContentProvider(new ContentProvider());
		schools = schoolTableViewer.getTable();
		schools.addMouseListener(new MouseAdapter() {
			public void mouseDoubleClick(final MouseEvent e) {
				if (pageControl == null) {
					MessageDialog.openInformation(e.display.getActiveShell(),
							IMessageKeys.FAIL, "请先进行查询!");
					return;
				}
				IStructuredSelection selection = (IStructuredSelection) schoolTableViewer
						.getSelection();
				School school = (School) selection
						.getFirstElement();
				if (school == null) {
					MessageDialog.openInformation(e.display.getActiveShell(),
							IMessageKeys.FAIL, "请先选择一条记录!");
				} else {
					SchoolDialog dialog = new SchoolDialog(
							getViewSite().getShell());
					dialog.setSchool(school);
					dialog.open();
				}
			}
		});
		schools.setLinesVisible(true);
		schools.setHeaderVisible(true);
		schools.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
		new Label(container, SWT.NONE);

		final Button btnView = new Button(container, SWT.NONE);
		btnView.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent e) {
				if (pageControl == null) {
					MessageDialog.openInformation(e.display.getActiveShell(),
							IMessageKeys.FAIL, "请先进行查询!");
					return;
				}
				IStructuredSelection selection = (IStructuredSelection) schoolTableViewer
						.getSelection();
				School school = (School) selection
						.getFirstElement();
				if (school == null) {
					MessageDialog.openInformation(e.display.getActiveShell(),
							IMessageKeys.FAIL, "请先选择一条记录!");
				} else {
					SchoolDialog dialog = new SchoolDialog(
							getViewSite().getShell());
					dialog.setSchool(school);
					dialog.open();
				}
			}
		});
		btnView.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1));
		btnView.setText("查看学校明细");
		new Label(container, SWT.NONE);
		
		initializeTableViewer();
		initializeServices();
		setupValues();
		
		//
		createActions();
		initializeToolBar();
		initializeMenu();
	}

	public static final String SCHOOL_NAME = "学校名称";
	public static final String COUNTRY_NAME = "国家";
	public static final String COPARTNER = "合作方";
	public static final String PUBLIC = "公私立";
	public static final String PROPERTY = "学校性质";
	public static final String STATE = "所在州";
	public static final String CITY = "所在市";
	public static final String DOUBLE_MATRICULATE = "双录取";
	public static final String ENTER_REQUIREMENT = "入学要求";
	public static final String PHONE_INTERVIEW = "电话面试";
	public static final String FEE = "学费";
	public static final String LANG_REQ = "语言要求";
	public static final String APPLY_FEE = "申请费";
	public static final String APPLY_END_DATE = "申请截止日期";
	public static final String GRADUATE_RATE = "毕业率";
	public static final String RANK = "学校排名";
	public static final String STUDENT_COUNT = "学生人数";
	public static final String OVERSEA_STUDENT_RATE = "海外学生比例";
	public static final String SCHOLARSHIP = "奖学金";
	public static final String WEBSITE = "网址";
	public static final String REMARK = "备注";
	
	private void initializeTableViewer() {
		/*createSortedTableColumn(schoolTableViewer, SWT.CENTER, SCHOOL_ID, "", 120,
				new SchoolIdSorter(), SWT.UP, false, null).chooseColumnForSorting();*/
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, SCHOOL_NAME, "", 120,
				new SchoolNameSorter(), SWT.UP, false, null).chooseColumnForSorting();
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, COUNTRY_NAME, "", 80,
				new CountryNameSorter(), SWT.UP, false, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, COPARTNER, "", 120, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, PUBLIC, "", 80, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, PROPERTY, "", 100, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, STATE, "", 120, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, CITY, "", 120, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, DOUBLE_MATRICULATE, "", 60, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, ENTER_REQUIREMENT, "", 150, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, PHONE_INTERVIEW, "", 80, null);
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, FEE, "", 80,
				new FeeSorter(), SWT.UP, false, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, LANG_REQ, "", 120, null);
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, APPLY_FEE, "", 80,
				new ApplyFeeSorter(), SWT.UP, false, null);
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, APPLY_END_DATE, "", 100,
				new ApplyEndDateSorter(), SWT.UP, false, null);
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, GRADUATE_RATE, "", 80,
				new GraduateRateSorter(), SWT.UP, false, null);
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, RANK, "", 80,
				new RankSorter(), SWT.UP, false, null);
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, STUDENT_COUNT, "", 80,
				new StudentCountSorter(), SWT.UP, false, null);
		createSortedTableColumn(schoolTableViewer, SWT.CENTER, OVERSEA_STUDENT_RATE, "", 100,
				new OverseaStudentRateSorter(), SWT.UP, false, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, SCHOLARSHIP, "", 120, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, WEBSITE, "", 120, null);
		createTableColumn(schoolTableViewer, SWT.CENTER, REMARK, "", 120, null);
	}
	
	@SuppressWarnings("unchecked")
	private void buildQueryConditions() {
		conditions = new HashMap();
		if (StringUtils.isNotEmpty(txtName.getText())) {
			conditions.put("schoolName", txtName.getText());
		}
		if (comboPublic.getSelectionIndex() >= 0) {
			conditions.put("public", comboPublic.getSelectionIndex() == 0 ? true : false);
		}
		if (comboProperty.getSelectionIndex() >= 0) {
			conditions.put("property", properties[comboProperty.getSelectionIndex()]);
		}
		if (comboScholarship.getSelectionIndex() >= 0) {
			conditions.put("scholarship", comboScholarship.getSelectionIndex());
		}
		if (comboCountry.getSelectionIndex() >= 0) {
			conditions.put("countryId", countryIds.get(comboCountry.getSelectionIndex()));
		}
		if (StringUtils.isNotEmpty(txtState.getText())) {
			conditions.put("state", txtState.getText());
		}
		if (StringUtils.isNotEmpty(txtSpeciality.getText())) {
			conditions.put("speciality", txtSpeciality.getText());
		}
	}
	
	private void pageQuery() {
		schoolService.pageQuery(pageControl, conditions);
		schoolTableViewer.setInput(pageControl.getPageData());
		lblResult.setText("查询结果共 " + pageControl.getRowCount() + " 条记录");
		lblPage.setText("页码(每页显示" + PAGE_SIZE + "条): " + pageControl.getPageNo() + "/" + pageControl.getPageCount());
		schools.deselectAll();
	}

	private SchoolService schoolService;
	
	private void initializeServices() {
		schoolService = (SchoolService) SpringBeanFactory.getBean("schoolService");
	}
	
	List<Integer> countryIds = new ArrayList<Integer>();
	
	private void setupValues() {
		List<Country> countries = CountryCache.getInstance().getAllCountries();
		if (countries != null) {
			for (Country country : countries) {
				countryIds.add(country.getId());
				comboCountry.add(country.getName());
			}
		}
	}

	/**
	 * Create the actions
	 */
	private void createActions() {
		// Create the actions
	}

	/**
	 * Initialize the toolbar
	 */
	private void initializeToolBar() {
	}

	/**
	 * Initialize the menu
	 */
	private void initializeMenu() {
	}

	@Override
	public void setFocus() {
		// Set the focus
	}
	
	// Convenience class which avoids casting in subclasses
	private abstract class AbstractSorter extends AbstractInvertableTableSorter {
		public int compare(Viewer viewer, Object o1, Object o2) {
			return compare((School) o1, (School) o2);
		}
		public abstract int compare(School c1, School c2);
	}
	private class SchoolNameSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return Collator.getInstance().compare(c1.getName(), c2.getName());
		}
	}
	private class CountryNameSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return Collator.getInstance().compare(c1.getCountry().getName(),
					c2.getCountry().getName());
		}
	}
	private class FeeSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return c1.getFee().compareTo(c2.getFee());
		}
	}
	private class ApplyFeeSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return c1.getApplyFee().compareTo(c2.getApplyFee());
		}
	}
	private class ApplyEndDateSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return c1.getApplyEndDate().compareTo(c2.getApplyEndDate());
		}
	}
	private class GraduateRateSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return c1.getGraduateRate().compareTo(c2.getGraduateRate());
		}
	}
	private class RankSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return c1.getRank().compareTo(c2.getRank());
		}
	}
	private class StudentCountSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return c1.getStudentCount().compareTo(c2.getStudentCount());
		}
	}
	private class OverseaStudentRateSorter extends AbstractSorter {
		public int compare(School c1, School c2) {
			return c1.getOverseaStudentRate().compareTo(c2.getOverseaStudentRate());
		}
	}

}
